package com.hyperf.core.lock;

import com.hyperf.core.lock.exception.LockException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author lizhaoyang
 */
public class DefaultLockFailureStrategy implements LockFailureStrategy {

    private static final Logger logger = LoggerFactory.getLogger(DefaultLockFailureStrategy.class);

    @Override
    public void onLockFailure(String lockKey, long acquireTimeout, int acquireCount) throws LockException {
        logger.error("thread:{} acquire lock fail,lockKey:{} acquireTimeout:{}ms, acquireCount:{}",
                Thread.currentThread().getName(), lockKey, acquireTimeout, acquireCount);

        throw new LockException("acquire lock fail");
    }
}
